package com.ymatou.iapi.userservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.userservice.parameter.ExistsLoginBillsRequestDtoBean;
import com.ymatou.iapi.userservice.parameter.enums.BillsActionTypeEnum;
import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymatou.iapi.userservice.service.ExistsLoginBillsRequestDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
/**
*用户服务查询是否存在相同的凭据,及凭据被非当前用户使用Test
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_ExistsLoginBillsRequestDto{
	private static ExistsLoginBillsRequestDtoBean existsloginbillsrequestdtoBean;
	private static ExistsLoginBillsRequestDtoCall existsloginbillsrequestdtoCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("用户服务查询是否存在相同的凭据,及凭据被非当前用户使用Test");
	}

	@Before
	public void caseUp() {
		existsloginbillsrequestdtoBean=new ExistsLoginBillsRequestDtoBean();
		existsloginbillsrequestdtoCall=new ExistsLoginBillsRequestDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(existsloginbillsrequestdtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ExistsLoginBillsRequestDto_001() {
		Logger.start(true,"查询是否存在相同的凭据,成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
			existsloginbillsrequestdtoBean.setAction(BillsActionTypeEnum.CheckIsExistsSameBills);
			existsloginbillsrequestdtoBean.setLoginId(cur.getLoginId());
			existsloginbillsrequestdtoBean.setMail(cur.getMail());
			existsloginbillsrequestdtoBean.setMobile(cur.getMobile());
			existsloginbillsrequestdtoBean.setUserId(uid);
			existsloginbillsrequestdtoCall.setData(existsloginbillsrequestdtoBean);
			existsloginbillsrequestdtoCall.callService();	
			
			Logger.verifyEquals("Success",
					existsloginbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("Code").getAsString(),
					"验证Code");
			Logger.verifyEquals("true", existsloginbillsrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", existsloginbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ExistsLoginBillsRequestDto_002() {
		Logger.start(true,"存在相同的mail,成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
			existsloginbillsrequestdtoBean.setAction(BillsActionTypeEnum.CheckIsExistsSameBills);
			existsloginbillsrequestdtoBean.setLoginId(cur.getLoginId());
			existsloginbillsrequestdtoBean.setMail("Pmh51N33v4Z@taobao.com");
			existsloginbillsrequestdtoBean.setMobile(cur.getMobile());
			existsloginbillsrequestdtoBean.setUserId(uid);
			existsloginbillsrequestdtoCall.setData(existsloginbillsrequestdtoBean);
			existsloginbillsrequestdtoCall.callService();	
			
//			Logger.verifyEquals("MailOtherUserUsed",
//					existsloginbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("Code").getAsString(),
//					"验证Code");
			Logger.verifyEquals("true", existsloginbillsrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", existsloginbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
			//Logger.verifyIsContains("邮箱已被他用户使用", existsloginbillsrequestdtoCall.getString("LastErrorMessage"), "验证LastErrorMessage");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ExistsLoginBillsRequestDto_003() {
		Logger.start(true,"uid为空,失败");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
			existsloginbillsrequestdtoBean.setAction(BillsActionTypeEnum.CheckIsExistsSameBills);
			existsloginbillsrequestdtoBean.setLoginId(cur.getLoginId());
			existsloginbillsrequestdtoBean.setMail(cur.getMail());
			existsloginbillsrequestdtoBean.setMobile(cur.getMobile());
			//existsloginbillsrequestdtoBean.setUserId(uid);
			existsloginbillsrequestdtoCall.setData(existsloginbillsrequestdtoBean);
			existsloginbillsrequestdtoCall.callService();	
			
			Logger.verifyEquals("EmailAlreadyExists",
					existsloginbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("Code").getAsString(),
					"验证Code");
			Logger.verifyEquals("false", existsloginbillsrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("400", existsloginbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
			Logger.verifyIsContains("邮箱地址已存在", existsloginbillsrequestdtoCall.getString("LastErrorMessage"), "验证LastErrorMessage");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_ExistsLoginBillsRequestDto_004() {
		Logger.start(true,"mail为空,成功");
		try {
			CreateUserReq cur = new CreateUserReq();
			cur = JUserCallService.initCreateUserBean(cur);
			Integer uid = JUserCallService.createUserCall(cur);
			
			existsloginbillsrequestdtoBean.setAction(BillsActionTypeEnum.CheckIsExistsSameBills);
			existsloginbillsrequestdtoBean.setLoginId(cur.getLoginId());
			//existsloginbillsrequestdtoBean.setMail(cur.getMail());
			existsloginbillsrequestdtoBean.setMobile(cur.getMobile());
			existsloginbillsrequestdtoBean.setUserId(uid);
			existsloginbillsrequestdtoCall.setData(existsloginbillsrequestdtoBean);
			existsloginbillsrequestdtoCall.callService();	
			
			Logger.verifyEquals("Success",
					existsloginbillsrequestdtoCall.getJsonObject().get("Result").getAsJsonObject().get("Code").getAsString(),
					"验证Code");
			Logger.verifyEquals("true", existsloginbillsrequestdtoCall.getString("Success"), "验证Success");
			Logger.verifyEquals("200", existsloginbillsrequestdtoCall.getString("ResponseCode"), "验证ResponseCode");
			//Logger.verifyIsContains("邮箱地址已存在", existsloginbillsrequestdtoCall.getString("LastErrorMessage"), "验证LastErrorMessage");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}